package com.gtw.modules.base.controller;

import com.gtw.common.utils.R;
import com.gtw.modules.base.service.TbCityService;
import com.gtw.modules.entity.TbCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** 城市Controller
 * Created by wuye on 2018/1/26.
 */
@RestController
@RequestMapping("/locl/city")
public class TbCityController {

    @Autowired
    private TbCityService tbCityService;

    /**
     * 根据省份ID查询城市
     * @param provinecid
     * @return
     */
    @GetMapping(value = "/list")
    public R findByProinecId(@RequestParam("provinecid") int provinecid){
        List<TbCity> list = tbCityService.findbyProvinecId(provinecid);
        return R.ok().put("list",list);
    }


    /**
     * 根据城市ID查询
     * @param cityid
     * @return
     */
    @GetMapping("/findByCityId")
    public R findByCityId(@RequestParam("cityid") int cityid){
        TbCity tbCity = tbCityService.findByCityId(cityid);
        return R.ok().put("tbCity",tbCity);
    }
}
